﻿using Furion;
using Furion.DynamicApiController;
using GWB.Application.Common;
using GWB.Application.System.OrgManage.Dtos;
using GWB.Application.System.OrgManage.OrgService;
using GWB.Core;
using GWB.Core.Enum;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWB.Application.System.OrgManage
{
    /// <summary>
    /// 组织管理
    /// </summary>
    [ApiDescriptionSettings("系统管理", Tag = "组织管理", SplitCamelCase = false)]
    public class OrgAppService : IDynamicApiController
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "新增组织", Code = AuthCode.Add)]
        public async Task<Result<OrgOutDto>> Add(OrgCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IOrgService>().Add(inputDto);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [Authorization(Name = "删除组织", Code = AuthCode.Delete)]
        public async Task<bool> Delete(List<long> ids)
        {
            return await App.GetService<IOrgService>().Delete(ids);
        }


       

        /// <summary>
        /// 修改组织
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "修改组织", Code = AuthCode.Update)]
        public async Task<bool> Update(OrgCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IOrgService>().Update(inputDto);
        }

        /// <summary>
        /// 获取组织树
        /// </summary>
        /// <returns></returns>
        [Authorization(Name = "查询组织(树)", Code = AuthCode.Page)]
        public async Task<List<OrgTreeOutDto>> GetOrgTree()
        {
            return await App.GetService<IOrgService>().GetOrgTree();
        }

    }
}
